#include "NaTools.hpp"
#include <iostream>
#include <fstream>
using namespace std;

const int N = 10000;
const double _left = 0;
const double _right = 2;
double step = (_right-_left)/N;

inline double pow(double x,int p){
	double ans = 1;
	for(int i=0;i<p;i++) ans*=x;
	return ans;	
}

double coff[] = {1,-8,28,-56,70,-56,28,-8,1};
class poly:public func{
public:
    double operator ()(double x){
		double ans = 0;
		for(int i=8;i>=0;i--) ans += coff[8-i]*pow(x,i);
		return ans;
	}
};

class qin_jiu:public func{
public:
    double operator ()(double x){
		double ans = 0;
		for(int i=0;i<=8;i++){
			ans*=x;
			ans+=coff[i];
		}
		return ans;
	}
};

class my_ans:public func{
public:
double operator ()(double x){
		return pow(x-1,8);
	}
};

poly A; qin_jiu B; my_ans C;

ofstream outfile;
vector<double> x;

void init(){
	double loc = _left;
	for(int i=0;i<=N;i++){
		x.push_back(loc);
		loc+=step;
	}
	outfile << "[" ;
	for(int i=0;i<=N;i++){
		if(i==N) outfile << A(x[i]);
		else outfile << A(x[i]) << ",";
	}
	outfile << "]" << endl;
	outfile << "[" ;
	for(int i=0;i<=N;i++){
		if(i==N) outfile << B(x[i]);
		else outfile << B(x[i]) << ",";
	}
	outfile << "]" << endl;
	outfile << "[" ;
	for(int i=0;i<=N;i++){
		if(i==N) outfile << C(x[i]);
		else outfile << C(x[i]) << ",";
	}
	outfile << "]" << endl;
}

int main(){
	outfile.open("plot_scale.dat");
	outfile << N << " " << _left << " " << _right << endl;
	init();
	outfile.close();
}